﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using IronCow;
using Milkify.Data;
using Milkify.Interfaces;

namespace Milkify.Views
{
    public partial class TaskControl : Page, IView
    {
        public const string NameParameter = "Name";
        public const string PriorityParameter = "Priority";
        public const string DueParameter = "DueDate";
        public const string RepeatParameter = "Repeat";
        public const string EstimateParameter = "Estimate"; 
        public const string UrlParameter = "Url";
        public const string LocationParameter = "Location";

        public TaskControl()
        {
            InitializeComponent();
        }

        private void TaskUrl_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            e.Handled = true;
            System.Diagnostics.Process.Start(e.Uri.ToString());
        }

        #region IView Members

        public object ViewData
        {
            get { return DataContext; }
            set
            {
                DataContext = value;

                if (value != null)
                {
                    Task task = ((TaskViewData)value).Task;
                    if (task.IsIncomplete)
                    {
                        IncompleteTaskFunctions.Visibility = Visibility.Visible;
                        CompletedTaskFunctions.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        IncompleteTaskFunctions.Visibility = Visibility.Collapsed;
                        CompletedTaskFunctions.Visibility = Visibility.Visible;
                    }
                }
            }
        }

        #endregion
    }
}
